package cn.lbaicai.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

public class Myfilter implements Filter {
	public Logger logger = Logger.getLogger(Myfilter.class);

	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub
		String username = filterConfig.getInitParameter("username");  
		logger.info("init.............");
		logger.info("init...username"+username);
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		logger.info("doFilter.............");
		 // 转换成实例的请求和响应对象  
        HttpServletRequest req = (HttpServletRequest) request;  
        HttpServletResponse resp = (HttpServletResponse) response;  
        logger.info("doFilter before");  
        chain.doFilter(req, resp);  
        logger.info("doFilter after");  
		// TODO Auto-generated method stub
		
	}

	public void destroy() {
		// TODO Auto-generated method stub
		logger.info("destroy.............");
		
	}

}
